package com.jic.member.impl;

import java.lang.Long;
import java.util.List;


import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.member.entity.RuleObtain;
import com.jic.member.mapper.RuleObtainMapper;
import com.jic.member.service.RuleObtainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 积分获取规则详情表
 * @author : 
 * @email : 
 * @since : 2020-01-15 08:28:14
 * @version : v1.0.0
 */
@Service
public class RuleObtainServiceImpl implements RuleObtainService {

    @Autowired
    private RuleObtainMapper ruleObtainMapper;

    @Override
    public long insert(RuleObtain ruleObtain) {
        long flag = ruleObtainMapper.insert(ruleObtain);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return ruleObtainMapper.delete(id);
    }

    @Override
    public long deleteByRuleInfoId(Long ruleInfoId) {
        return ruleObtainMapper.deleteByRuleInfoId(ruleInfoId);
    }

    @Override
    public long update(RuleObtain ruleObtain) {
        return ruleObtainMapper.update(ruleObtain);
    }

    @Override
    public long updateByRuleInfoId(RuleObtain ruleObtain) {
        return ruleObtainMapper.updateByRuleInfoId(ruleObtain);
    }

    @Override
    public RuleObtain queryByPrimaryKey(Long id){
        return ruleObtainMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<RuleObtain> query(RuleObtain ruleObtain){
        return ruleObtainMapper.query(ruleObtain);
    }

    @Override
    public PageResult<RuleObtain> queryPage(RuleObtain ruleObtain, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<RuleObtain> list = ruleObtainMapper.queryPage(startIndex, pageQuery.getLimit(), ruleObtain);
        long count = ruleObtainMapper.queryPageCount(ruleObtain);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}